#!/usr/bin/env node

const cp = require('child_process'),
  argv = process.argv;
let cmd = '',
  arg = [];
if(argv.length == 2){
  cmd = 'cat';
  arg.push('01-exec-file.js');
}else{
  cmd = argv[2];
  arg = argv.slice(3,argv.length);
}

cp.execFile(cmd,arg,(err,stdout)=>{
  if(err){
    console.error(err.message);
    process.exit(1);
  }
  console.log(stdout);
});

//console.log(process.env);

//cp.execFile('cat',['../00.js'],(error,out,err)=>{
//  if(error){
//    console.error(err.toString('utf8'));
//  }
//  else{
//    console.log(out.toString('utf8'));
//  }
//});



//console.log('hello world');
